function judgeCanUse(start, end, usedTime) {
    const today = new Date()
    const todayStr = today.getFullYear() + `/${today.getMonth()+1}` + `/${today.getDate()}`
    const intersection = [] // 缓存冲突的时间段
    usedTime.forEach((tm) => {
        const ta = tm.split('-')
        const ts = new Date(`${todayStr} ${ta[0]}:00`).getTime() // 时间段起点
        const te = new Date(`${todayStr} ${ta[1]}:00`).getTime() // 时间段终点
        const st = new Date(`${todayStr} ${start}:00`).getTime() // 开始时间
        const et = new Date(`${todayStr} ${end}:00`).getTime() // 结束时间
        /* 开始时间在时间段终点后 或 结束时间在时间段起点前 */
        if (st >= te || et <= ts) {

        } else {
            intersection.push(tm)
        }
    })
    // console.log(start, end, intersection)
    return intersection
}
function zero(n) {
    return n < 10 ? `0${n}` : n
}
function formatTs (ts) {
    const date = new Date(ts)
    const year = date.getFullYear()
    const month = date.getMonth() + 1
    const day = date.getDate()
    const hour = date.getHours()
    const minute = date.getMinutes()
    const second = date.getSeconds()
    return `${year}-${zero(month)}-${zero(day)} ${zero(hour)}:${zero(minute)}:${zero(second)}`
}
export default {
    judgeCanUse,
    formatTs,
}
